home *** CD-ROM | disk | FTP | other *** search
-
- This is a patch against nfsd-2.0 that implements per-call
- profiling of the nfs server. Apply this patch, compile with
- -DCALL_PROFILING, run your favorite nfs benchmark and send
- SIGIOT to nfsd. The averaged execution times per procedure
- should be in /tmp/nfsd.profile.
-
- This patch is already incorporated in nfsd-2.2. If
- you find that the stats for some calls differ significantly
- between 2.0 and 2.2 versions, please let me know. I've had
- a couple of reports about performance problems, but was not
- able to pin them down.
-
- Olaf <okir@monad.swb.de>
-
- --- dispatch.c.orig Tue Dec 28 04:58:32 1993
- +++ dispatch.c Thu May 18 00:07:47 1995
- @@ -105,6 +105,20 @@
-
- static _PRO( void set_ids, (struct svc_req *rqstp) );
-
- +#ifdef CALL_PROFILING
- +#define PATH_PROFILE "/tmp/nfsd.profile"
- +
- +static struct timeval rtimes[18] = {
- + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
- + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
- + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}
- +};
- +static int calls[18] = {
- + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- +};
- +static struct timeval t0, t1;
- +#endif
- +
- void nfs_dispatch(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
- @@ -129,6 +143,10 @@
- /* Log the call. */
- log_call(rqstp, dent->name, dent->log_print(&argument));
-
- +#ifdef CALL_PROFILING
- + gettimeofday(&t0, NULL);
- +#endif
- +
- /* Initialize our variables for determining the attributes of
- the file system in nfsd.c */
- svc_rqstp = rqstp;
- @@ -162,7 +180,51 @@
- dprintf(0, "unable to free RPC arguments, exiting\n");
- exit(1);
- }
- +#ifdef CALL_PROFILING
- + gettimeofday(&t1, NULL);
- +
- + if (t1.tv_usec < t0.tv_usec) {
- + rtimes[proc_index].tv_sec += t1.tv_sec - t0.tv_sec - 1;
- + rtimes[proc_index].tv_usec += 1000000 + t1.tv_usec - t0.tv_usec;
- + } else {
- + rtimes[proc_index].tv_sec += t1.tv_sec - t0.tv_sec;
- + rtimes[proc_index].tv_usec += t1.tv_usec - t0.tv_usec;
- + }
- + calls[proc_index]++;
- +#endif
- +
- +}
- +
- +#ifdef CALL_PROFILING
- +void
- +dump_stats(int sig)
- +{
- + FILE *fp;
- + int i;
- +
- + signal (sig, dump_stats);
- +
- + if ((fp = fopen(PATH_PROFILE, "w")) == NULL) {
- + dprintf(0, "unable to write profile data to %s\n",
- + PATH_PROFILE);
- + return;
- + }
- +
- + for (i = 0; i < 18; i++) {
- + float t;
- +
- + t = (float) rtimes[i].tv_sec +
- + (float) rtimes[i].tv_usec / 1000000.0;
- + fprintf(fp, "%-20s\t%5d calls %8.4f sec avg\n",
- + dtable[i].name, calls[i],
- + (calls[i])? t / calls[i] : 0);
- + rtimes[i].tv_sec = rtimes[i].tv_usec = 0;
- + calls[i] = 0;
- + }
- +
- + fclose (fp);
- }
- +#endif
-
- static void set_ids(rqstp)
- struct svc_req *rqstp;
- --- nfsd.c.orig Thu May 18 00:08:12 1995
- +++ nfsd.c Thu May 18 00:09:15 1995
- @@ -50,6 +50,9 @@
- static _PRO(nfsstat build_path, (char *buf, diropargs * da));
- static _PRO(int makesock, (int port, int proto, int socksz));
- static _PRO(void closedown, (int sig));
- +#ifdef CALL_PROFILING
- +extern _PRO(void dump_stats, (int sig));
- +#endif
-
- extern void xdr_free(); /* fill this in later */
- extern void pmap_unset(); /* why here??? */
- @@ -953,6 +956,9 @@
-
- /* Enable the LOG toggle with a signal. */
- signal(SIGUSR1, toggle_logging);
- +#ifdef CALL_PROFILING
- + signal(SIGIOT, dump_stats);
- +#endif
-
- if (_rpcpmstart) {
- signal(SIGALRM, closedown);
-